package WeekThree;

import java.util.Arrays;
import java.util.Scanner;

public class Sort {
    //插入排序
    public static void main(String[] args) {
        int[]arr=new int[6];
        System.out.println("排序前");
        Sort.Cha(arr);
        System.out.println("排序后:");
        System.out.println(Arrays.toString(arr));
    }
    public static void Cha(int[] arr) {
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i<arr.length; i++){
            arr[i] = scanner.nextInt();
            for (int j = i-1; j>=0; j--){
                if(arr[j]>arr[j+1]){
                    int r = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = r;
                }else
                    break;
            }
        }
    }
}
